#include "proxyadder.h"
#include "ui_proxyadder.h"

ProxyAdder::ProxyAdder(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProxyAdder)
{
    ui->setupUi(this);
    ProxyAdderItem* tmp=new ProxyAdderItem(QNetworkProxy(), this);
//    list.append(tmp);
//    if(ui->frame->layout()!=NULL){
//        delete ui->frame->layout();
//    }
    ui->frame->setLayout(new QVBoxLayout(this));
    newProxy(tmp);
    connect(tmp, SIGNAL(newProxy(ProxyAdderItem*)),this, SLOT(newProxy(ProxyAdderItem*)));
}

void ProxyAdder::newProxy(ProxyAdderItem*tmp){
    list.append(tmp);
    connect(tmp, SIGNAL(newProxy(ProxyAdderItem*)),this, SLOT(newProxy(ProxyAdderItem*)));
    QVBoxLayout* layout=(QVBoxLayout*)ui->frame->layout();
    if(layout->count()>0)
        layout->takeAt(layout->count()-1);
    layout->addWidget(tmp);
    layout->addStretch();

}

ProxyAdder::~ProxyAdder()
{
    delete ui;
}
